// This class describes everything that will be instantiated within a game map (buildings, characters, trees, etc)
// but not the actual map itself.

// Every BaseGameEntity will have a unique id equal to or greater than zero. The Entity Manager will keep track 
// of all of these. 
#ifndef BASE_GAME_ENTITY
#define BASE_GAME_ENTITY

#include "Entity.h"
#include "Vector2D.h"
#include <list>


class BaseGameEntity : public Entity
{
	enum flag
	{
		boundCircle =		0x00002,
		collisionCircle =	0x00004,
		selectionRect =		0x00008
	};
	
private:
	int m_iDrawFlags;
	static int m_iNextValidID;
	int m_ID;
	int NextValidID() {return m_iNextValidID;}

	// Every entity has a type (dragon, rock, food, etc.)
	int m_EntityType;

protected:
	Vector2D m_vPos;
	double m_dBoundingRadius;
	double m_dCollisionRadius;

	bool isMoving;
	bool selected;

	int OwnerID; // The ID of the player that owns this. 

	// BaseGameEntity is a virtual class, and, therefore, should not be declared
	BaseGameEntity(Vector2D pos, string name, int type);

public:

	virtual			~BaseGameEntity() {}

	virtual void	Update(double time_elapsed);
	virtual bool	HandleMessage(const Message &msg) {return true;}
	virtual void	Render();


	Vector2D		Pos()const{return m_vPos;}
	inline float	GetX() const {return m_vPos.x;}
	inline float	GetY() const {return m_vPos.y;}
	void			SetPos(Vector2D new_pos) {m_vPos = new_pos;}

	// Bounding Radii
	double			BRadius()const{return m_dBoundingRadius;}
	double			CRadius()const{return m_dCollisionRadius;}
	void			SetBRadius(double r){m_dBoundingRadius = r; m_dCollisionRadius = r*1.5;}

	// ID
	int				ID()const{return m_ID;}
	string			ID_String();

	// Entity Type
	int				EntityType()const{return m_EntityType;}
	void			SetEntityType(int new_type){m_EntityType = new_type;}

	bool			IsMoving() {return isMoving;}
	bool			IsBuilding() {return (m_EntityType >= 200 && m_EntityType < 300);}

	// Selection
	void			Select() {selected = true; selectionRectOn();}
	void			Deselect() {selected = false; selectionRectOff();}
	bool			Selected() {return selected;}

	// Turns on and off the flags
	void boundCircleOn();
	void collisionCircleOn();
	void selectionRectOn();

	void boundCircleOff();
	void collisionCircleOff();
	void selectionRectOff();

	// Checks to see if a flag has been switch
	bool On(flag bt);
	bool IsBoundCircleOn();
	bool IsCollisionCircleOn();
	bool IsSelectionRectOn();

};

#endif